package com.kbt.util.tool;

import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;
import com.kbt.activity.R;

/**
 * @author zhgk
 * @package: com.kbt.widget
 * @TODO: 设置弹出窗口的样式
 * @data: 2015/8/11 11:15
 * @version: V1.0
 */
public class PopWindowSetting {
    /***
     * 设置弹出窗口的样式
     *
     * @param popWindow
     */

    public static void setPopWindowStyle(PopupWindow popWindow) {

        //设置长宽高
        popWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        popWindow.setHeight(R.dimen.PopWindowHeight);
        //设置点击外部取消
        popWindow.setFocusable(true);
        popWindow.setOutsideTouchable(true);
        //设置背景透明
        ColorDrawable dw = new ColorDrawable(0xb0000000);
        popWindow.setBackgroundDrawable(dw);
        popWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);

    }

    /**
     * 设置父窗体背景
     *
     * @param context
     * @param alpha
     */
    public static void setParentBackGround(Activity context, float alpha) {
        WindowManager.LayoutParams lp = context.getWindow().getAttributes();
        lp.alpha = alpha;
        context.getWindow().setAttributes(lp);
    }


}
